<?php
/**
 * @Notes:【】
 * @User: zwc
 * @Date: 2022-05-09 0:20
 */

namespace App\Listener\WebSocket\Message;

use App\Event\Talk\ChatEvent;
use App\Event\Talk\ChatReadEvent;
use App\Service\WebSocket\Message\ChatService;
use App\WsService\Chat\ChatRecordsService;
use App\WsService\Chat\ChatSessionService;
use Hyperf\Event\Annotation\Listener;
use Hyperf\Event\Contract\ListenerInterface;


/**
 * @Listener()
 */
class ChatReadListener implements ListenerInterface
{

    public function listen(): array
    {
        return [
            ChatReadEvent::class
        ];
    }

    public function process(object $event)
    {
//        if ($event instanceof ChatEvent) {
//            /** @var ChatEvent $ChatEvent */
////            $ChatEvent = $event;
//            //记录消息
//            App(ChatService::class)->handle($event);
//        }
//        //插入数据
//        dump($event);
        dump($event->friend_id, $event->user_id);
        App(ChatRecordsService::class)->read($event->friend_id, $event->user_id);

        // TODO: Implement process() method.
    }
}